//
//  LiveView.m
//  BasketballClub
//
//  Created by 孙鸿吉 on 16/1/6.
//  Copyright © 2016年 孙鸿吉. All rights reserved.
//

#import "LiveView.h"
#pragma mark -  初始化
@implementation LiveView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self allViews];
    }
    return self;
}
#pragma mark - 布局子视图(segmentControl的布局)
-(void)allViews
{
    
       //segment数组
    NSArray *array = @[@"昨日赛程",@"今日赛程",@"明日赛程"];
//    UILabel *lable1 = [[UILabel alloc]init];
//    lable1.text = @"昨日赛程";
//    lable1.font = [UIFont systemFontOfSize:20*LAYOUT_SIZE];
//    UILabel *lable2 = [[UILabel alloc]init];
//    lable2.text = @"今日赛程";
//    lable1.font = [UIFont systemFontOfSize:20*LAYOUT_SIZE];
//
//    UILabel *lable3 = [[UILabel alloc]init];
//    lable3.text = @"明日赛程";
//    lable1.font = [UIFont systemFontOfSize:20*LAYOUT_SIZE];
//
//    NSArray *array =@[lable1.text,lable2.text,lable3.text];
    //初始化segment
    self.segmentControl = [[UISegmentedControl alloc]initWithItems:array];

    //设置segment的frame
    self.segmentControl.frame = CGRectMake(0, 64*LAYOUT_SIZE_HEIGHT, SCREEN_WIDTH, 40*LAYOUT_SIZE_HEIGHT);


//    self.segmentControl.momentary = YES;
    
    self.segmentControl.tintColor = [UIColor clearColor];//去掉颜色,现在整个segment都看不见
    NSDictionary* selectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18*LAYOUT_SIZE],
                                             NSForegroundColorAttributeName: [UIColor yellowColor]};
    [self.segmentControl setTitleTextAttributes:selectedTextAttributes forState:UIControlStateSelected];//设置文字属性
    NSDictionary* unselectedTextAttributes = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18*LAYOUT_SIZE],
                                               NSForegroundColorAttributeName: [UIColor whiteColor]};
    [self.segmentControl setTitleTextAttributes:unselectedTextAttributes forState:UIControlStateNormal];
    //设置semgment默认的位置
    self.segmentControl.selectedSegmentIndex = 1;

    //设置背景图
    [self.segmentControl setBackgroundImage:[UIImage imageNamed:@"segment2.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

    
    [self addSubview:self.segmentControl];
    
    [self replaceNAvigationBar];
    
    
    

    
    
    
}







#pragma mark - 替换导航栏
-(void)replaceNAvigationBar
{
    
    self.rView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64*LAYOUT_SIZE_HEIGHT)];
    self.rView.backgroundColor =ColorHex(0x0d1c38);
    [self addSubview:self.rView];
    
    self.rLabel =[[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH/2 - (25 * LAYOUT_SIZE), 29 * LAYOUT_SIZE_HEIGHT, 50* LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    self.rLabel.text = @"赛程";
    self.rLabel.textColor = [UIColor yellowColor];
    self.rLabel.textAlignment = 1;
    self.rLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:17*LAYOUT_SIZE];
    
    [self.rView addSubview:self.rLabel];
    self.rButton = [[UIButton alloc]initWithFrame:CGRectMake(10 * LAYOUT_SIZE, 29 * LAYOUT_SIZE_HEIGHT, 50 * LAYOUT_SIZE, 26 * LAYOUT_SIZE_HEIGHT)];
    [self.rButton setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    self.rButton.titleLabel.font = [UIFont systemFontOfSize:17*LAYOUT_SIZE];
    [self.rButton setTitle:@"查询" forState:UIControlStateNormal];
    [self.rView addSubview:self.rButton];
    
    
    
    
    
}


@end
